package Dialogs
{
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.filters.GlowFilter;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;

	public class D1
	{
		public var display:Sprite = new Sprite();
		
		public var title_tf:TextField = new TextField();
		private var m_close_btn:Sprite = new Sprite();
		
		public var closeClickCallback:Function;
		
		public function D1(title:String, width:int, height:int)
		{
			var bg:Sprite = Util.getRoundRectSprite(width, height, 0x442266, 1, 15);
			display.addChild(bg);
			
			m_close_btn.addChild(ImageManager.getImage('assets/buttons/cancel24.png'));
			Util.buttonize(m_close_btn);
			m_close_btn.x = display.width - m_close_btn.width - Game.PADDING/2;
			m_close_btn.y = Game.PADDING/2;
			m_close_btn.addEventListener(MouseEvent.CLICK, onCloseClick);
			display.addChild(m_close_btn);
			
			Util.applyStyleH1(title_tf);
			title_tf.text = title;
			title_tf.wordWrap = true;
			title_tf.autoSize = TextFieldAutoSize.LEFT;
			title_tf.width = width- Game.PADDING*4;
			display.addChild(title_tf);
			title_tf.x = display.width/2 - title_tf.width/2;
			
			display.filters = [new GlowFilter(0xffffff,1, 12,12,15)];
		}
		
		public function onCloseClick(me:MouseEvent):void{
			if(this.closeClickCallback != null) this.closeClickCallback(me);
		}
	}
}